#include <iostream> 
using namespace std;
int main ()
{int m,t,u,f,d;
 char a[100000];
 cin>>m>>t>>u>>f>>d;
 for(int i=1;i<=t;i++)
   cin>>a[i];
 int s=0,n;
 for(int j=1;j<=t;j++)
   {if(s>m) {n=j;break;}
    if(a[j]=='u')  {s=s+u+d;}
       else 
          if(a[j]=='d')  {s=s+u+d;}
               else    s=s+f*2;
               }
 cout<<n-2<<endl; 
 system("pause");
 return 0;
}



